<html>

<head>
<title>我的第一个 HTML 页面</title>
<script src="jquery.min.js"></script>
<script>
    $.ajax({
        url:"http://0.0.0.0:5000/admin/index",
        type:"POST",
        dataType: 'json',
        success:function(res){
            console.log(res)
            // console.log(res + '+++++++++++++++++++++++++')
            var obj = document.getElementById("p");
            obj.innerHTML=res.user.length

            var len = res.user.length

            for(var i=0;i<len;i++){
                var frameDiv = document.createElement("p");
                var bodyFa = document.getElementById("user_name");
                bodyFa.appendChild(frameDiv);
                frameDiv.setAttribute("id", "p"+i);
                frameDiv.innerHTML = res.user[i]

                var p_fu = document.getElementById("p"+i);
                var del_ = document.createElement("button");
                p_fu.appendChild(del_);
                del_.innerHTML = "删除"
                del_.setAttribute('id','del'+i)

                var update_ = document.createElement("button");
                p_fu.appendChild(update_);
                update_.innerHTML = "更改"
                update_.setAttribute('id','update'+i)

            };
            var bodyFa = document.getElementById("user_name");
            var add = document.createElement("button");
            bodyFa.appendChild(add);
            add.innerHTML = "增加"
            add.setAttribute('id','add_but')

          },
        error:function (res) {
              console.log(000)
          }
    })

    

</script>
</head>

<body>
<p>body 元素的内容会显示在浏览器中。</p>
<p>title 元素的内容会显示在浏览器的标题栏中。</p>
<p id='p'></p>


<div id="user_name"></div>
<div id = "add_user">
    <p id = 'add_p'>

    </p>
    
</div>


<script>
    $(function(){
        $("#user_name").on('click','#add_but',function(){
            // $.ajax({
			// 	url:'http://0.0.0.0:5000/admin/command',

            //     type:"POST",
                
            //     dataType: 'json',
			// 	success:function(res){
            //         alert('请求成功');
            //     },
            //     error:function (res) {
            //         alert('请求失败');
            //     }
			// },
			// );

            var base = document.getElementById("add_p");

            var new_p = document.createElement("p");
            base.appendChild(new_p);
            new_p.setAttribute("id", "p_name");
            new_p.innerHTML = '请输入姓名:'

            var new_input = document.createElement("input");
            base.appendChild(new_input);
            new_input.setAttribute("id", "input_name");
            new_input.innerHTML = 'aaaaaa'

                

        })
    })
</script>

</body>

</html>
